#!/usr/bin/env bash

project_Name="nlpservice"

time=$(date "+%Y%m%d")

APP_HOME=`cd $(dirname $0)/..;pwd`
echo ${APP_HOME}
file_name=${APP_HOME##*/}

PROJECT_PATH=`cd $(dirname $0)/../..;pwd`

target_file="${PROJECT_PATH}/${file_name}.tar.gz"

time_dir="${PROJECT_PATH}/${time}"
echo ${time_dir}


#########判断文件是否存在############
if [ -f ${target_file} ];then
mkdir ${time_dir}
rm ${target_file}
tar -czvf ${target_file}  ${APP_HOME}
cp  -rf "${APP_HOME}/" "${time_dir}/${file_name}"
echo "上一版本压缩文件删除，现版本压缩完毕，工程文件保存完毕"
else
mkdir ${time_dir}
tar -czvf ${target_file}  ${APP_HOME}
cp  -rf "${APP_HOME}/" "${time_dir}/${file_name}"
echo "压缩完毕,工程文件保存完毕"
fi
